<template>
	<view>
		<view class="item">

			<u-icon name="order" color="#1573FF" label="审核意见" label-color="#333333"
				:customStyle="{'line-height': '80rpx','display': 'block','padding-left':'20rpx',}"></u-icon>

			<u-line color="#efefef" :customStyle="{'margin-bottom': '10rpx','display': 'block',}"></u-line>

			<view style="margin: 20rpx;">
				<u-textarea v-model="approveContent" placeholder="请输入审核意见" height="150"></u-textarea>
			</view>

		</view>


		<view class="bottom">
			<text @click="commit">{{1==type?'确认拒绝':
			2==type?'确认驳回':
			3==type?'确认通过':
			4==type||7==type?'审核通过':
			5==type?'确认撤回':
			6==type?'确认删除':
			''}}</text>

		</view>
	</view>
</template>

<script>
	import {
		k_api_orderDel,
		k_api_orderRecall,
		k_api_orderListapproven,
		k_api_orderRefuset,
		k_api_orderrReject,
		k_api_orderaApprove
	} from '@/common/http.api.js'

	export default {
		data() {
			return {
				type: 0,
				processKey: '',
				instanceId: '',
				carShiftId: '',
				approveId: '',
				nodeId: '',
				approveContent: '',
				exam_url: '',

				approveForm: {
					approveId: '',
					instanceId: '',
					processKey: '',
					nodeId: '',
					approveResult: 0,
					processOperationType: 0,
					approveContent: '',
				}
			}
		},
		methods: {
			commit() {
        let that = this;
        console.log('aaa', this.approveContent)

				if (uni.$u.test.isEmpty(this.approveContent)) {
					this.$u.toast('请输入审核意见')
					return
				}

				this.approveForm.approveContent = this.approveContent


				uni.showModal({
					content: '确定提交吗?',
					success(res) {
						if (res.confirm) {



							if (4 == that.type || 7 == that.type) {

								that.$u.api.cannibalizeAgree({
									carShiftId: that.carShiftId,
									approveForm: that.approveForm
								}).then(res => {
									that.$u.toast('提交成功')
                  uni.$emit('approval', true)
									setTimeout(() => {
										uni.navigateBack()
									}, 500)
								})
							} else {
								that.$u.api.cannibalizeRefes({
									carShiftId: that.carShiftId,
									approveForm: that.approveForm
								}).then(res => {
									that.$u.toast('提交成功')
                  uni.$emit('approval', true)
									setTimeout(() => {
										uni.navigateBack()
									}, 500)
								})
							}

						}
					}
				})
			}

		},
		onLoad(op) {
			//1拒绝  2驳回   3列表直接通过    4编辑后通过  5撤回   6删除   7审核页面直接通过

			this.type = op.type;
			this.processKey = op.processKey;
			this.instanceId = op.instanceId;
			this.carShiftId = op.carShiftId;
			this.approveId = op.approveId;
			this.nodeId = op.nodeId;

			this.approveForm.approveId = this.approveId
			this.approveForm.instanceId = this.instanceId
			this.approveForm.processKey = this.processKey
			this.approveForm.nodeId = this.nodeId


			if (1 == this.type) {
				uni.setNavigationBarTitle({
					title: '确认拒绝'
				})

				this.approveForm.approveResult = 2;
				this.approveForm.processOperationType = 2;

			} else if (2 == this.type) {
				uni.setNavigationBarTitle({
					title: '确认驳回'
				})
				this.approveForm.approveResult = 2;
				this.approveForm.processOperationType = 3;

			} else if (3 == this.type) {
				uni.setNavigationBarTitle({
					title: '确认通过'
				})
				this.approveForm.approveResult = 1;

			} else if (4 == this.type || 7 == this.type) {
				uni.setNavigationBarTitle({
					title: '确认通过'
				})
				this.approveForm.approveResult = 1;

			} else if (5 == this.type) {
				uni.setNavigationBarTitle({
					title: '确认撤回'
				})
				this.approveForm.approveResult = 2;
				this.approveForm.processOperationType = 1;

			} else if (6 == this.type) {
				uni.setNavigationBarTitle({
					title: '确认删除'
				})
			}
		},

	}
</script>

<style lang="scss" scoped>
	.bottom {
		position: fixed;
		width: 100%;
		height: 100rpx;
		bottom: 0;
		z-index: 999;
		background-color: white;
		display: flex;
		align-items: center;
		justify-content: center;

		text {
			width: 98%;
			height: 80rpx;
			line-height: 80rpx;
			border-radius: 50rpx;
			background-color: $blue15;
			color: white;
			text-align: center;
			font-size: 30rpx;
		}
	}
</style>
